#include "HttpRequest.h"
#include <map>

static std::map<std::string, Method> methods {
    {"GET", Method::kGet},
    {"POST", Method::kPost},
    {"HEAD", Method::kHead},
    {"PUT", Method::kPut},
    {"DELETE", Method::kDelete}
};

HttpRequest& HttpRequest::setMethod(const char* start, const char* end)
{
    assert(method_ == Method::kInvalid);
    std::string m(start, end);
    auto iter = methods.find(m);
    if (iter == methods.end())
        return *this;
    method_ = iter->second;
    return *this;
}

